﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class AdminDal
    {
        Mycontext db;
        public AdminDal(Mycontext db)
        {
            this.db = db;
        }
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public int Adminadd(Admin admin)
        {
            try
            {
                db.Admins.Add(admin);
                return db.SaveChanges();
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public dynamic login(string username, string password)
        {
            var info = db.Admins.FirstOrDefault(s => s.Name == username);
            return info;

        }
    }
}
